﻿namespace GbSpec.Interfaces

open System
open System.ComponentModel

type IFluentInterface = interface
       
        [<EditorBrowsable(EditorBrowsableState.Never)>]
        abstract Equals : (obj) -> bool

        [<EditorBrowsable(EditorBrowsableState.Never)>]
        abstract ToString: unit -> string

        [<EditorBrowsable(EditorBrowsableState.Never)>]
        abstract GetHashCode: unit -> int

        [<EditorBrowsable(EditorBrowsableState.Never)>]
        abstract GetType : unit -> Type
end  

type AssertionResult = | Passed | Failed | Inconclusive
type IAssertionConstraint = interface
     inherit IFluentInterface
     
     abstract equal<'a when 'a : equality> : 'a * 'a -> AssertionResult
            
     //   member x.be (actual:bool, expected:bool) = x.equal (actual, expected)
        
    //    member x.be<'a when 'a : not struct and 'a : equality> (actual : 'a , expected : 'a) = x.equal (actual, expected)
            
       
//        member x.failWith(codeBlock : (unit -> unit), expectedType : Type) =
//            try 
//              (new ThrowDelegate(codeBlock)).Invoke()
//             
//              String.Format("Expected exception of type {0}, but was never raised!", expectedType)
//              |> ExceptionNotRaisedException 
//              |> raise
//            with 
//              | ex  when (ex.GetType() <> expectedType) -> 
//                    String.Format("Expected exception of type {0}, but instead exception of type {1} was raised!", 
//                                   expectedType, ex.GetType())
//                    |> ExceptionNotRaisedException 
//                    |> raise
//              | _                                       -> Passed
//       
//        member x.contain (container:string, contained:string) =
//            match container, contained with
//            |  cr, cd when cr.Contains(cd)  -> Passed
//            |  cr, cd                       -> String.Format("[{0}] was expected to contain [{1}] but didn't.", cr, cd)
//                                               |> SpecFailedException
//                                               |> raise
//              
//        member x.contain<'a when 'a: equality>(items : 'a seq, item : 'a) =
//            match items, item with
//            | xs, x when xs |> Seq.exists (fun i -> i = x) -> Passed
//            | xs, x                                         -> String.Format("[{0}] was expected to contain [{1}] but didn't.", items, item)
//                                                               |> SpecFailedException
//                                                               |> raise
//    
end      